#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const int N = 32;
const int CN2 = N * (N - 1) / 2;

ll a[N][N];
int H, W, K;

ll dp[N][N];

ll solve(ll X) {
    memset(dp, 0x3f, sizeof(dp));

    dp[0][1] = dp[1][0] = 0;

    ll cnt = 0;

    for (int i = 1; i <= H; i++) {
        for (int j = 1; j <= W; j++) {
            dp[i][j] = min(dp[i-1][j], dp[i][j-1]);
            if (a[i][j] >= X) {
                dp[i][j] += a[i][j] - X;
                cnt ++;
            }
        }
    }

    if (cnt < K) return INT64_MAX; // 无解

    return dp[H][W] + 1ll*K*X;
}
int main() {
    cin >> H >> W >> K;
    for (int i = 1; i <= H; i++) for (int j = 1; j <= W; j++) cin >> a[i][j];

    ll res = INT64_MAX;
    for (int i = 1; i <= H; i++)
        for (int j = 1; j <= W; j++)
            res = min(res, solve(a[i][j]));

    cout << res << endl;
    return 0;
}